﻿using Time;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestTime
{
    using Time;

    [TestClass()]
    public class TimeTest
    {
        [TestMethod()]
        public void TimeConstructorTest()
        {
            int hours = 5; // TODO: Initialize to an appropriate value
            int minutes = 6; // TODO: Initialize to an appropriate value
            Time target = new Time(hours, minutes);
            Assert.AreEqual<int>(hours, target.Hours, "The hours was not correctly initialized");
            Assert.AreEqual<int>(minutes, target.Minutes, "The minutes was not correctly initialized");
        }
        
        [TestMethod()]
        public void op_SubtractionTest()
        {
            Time time = new Time(5,96); // TODO: Initialize to an appropriate value
            int minutes = 100; // TODO: Initialize to an appropriate value
            Time expected = new Time(4, 56); // TODO: Initialize to an appropriate value
            Time actual = (time - minutes);
            Assert.AreEqual<string>(expected.ToString(), actual.ToString(), "The Subtraction is not working");
        }

        [TestMethod()]
        public void HoursTest()
        {
            int hours = 63; // TODO: Initialize to an appropriate value
            int minutes = 26; // TODO: Initialize to an appropriate value
            Time target = new Time(hours, minutes); // TODO: Initialize to an appropriate value
            int actual;
            actual = target.Hours;
            Assert.AreEqual<int>(hours, actual, "Hours property is not working correctly");
        }

        [TestMethod()]
        public void MinutesTest()
        {
            int hours = 69; // TODO: Initialize to an appropriate value
            int minutes = 56; // TODO: Initialize to an appropriate value
            Time target = new Time(hours, minutes); // TODO: Initialize to an appropriate value
            int actual;
            actual = target.Minutes;
            Assert.AreEqual<int>(minutes, actual, "Minutes property is not working correctly");
        }

        [TestMethod()]
        public void op_AdditionTest()
        {
            Time time = new Time(2, 99); // TODO: Initialize to an appropriate value
            int minutes = 96; // TODO: Initialize to an appropriate value
            Time expected = new Time(5, 15); // TODO: Initialize to an appropriate value
            Time actual = (time + minutes);
            Assert.AreEqual<string>(expected.ToString(), actual.ToString(), "Addition operator is not working correctly");
        }

        [TestMethod()]
        [ExpectedException(typeof(Exception), "The time cannot be negative.")]
        public void CheckConstructor()
        {
            Time time = new Time(2, -3000);
        }

        [TestMethod()]
        public void ToStringTest()
        {
            int hours = 5; // TODO: Initialize to an appropriate value
            int minutes = 120; // TODO: Initialize to an appropriate value
            Time target = new Time(hours, minutes); // TODO: Initialize to an appropriate value
            string expected = "7 hours and 0 minutes"; // TODO: Initialize to an appropriate value
            string actual = target.ToString();
            actual = target.ToString();
            Assert.AreEqual<string>(expected, actual);
        }

        [TestMethod()]
        public void op_DecrementTest()
        {
            Time time = new Time(9, 0); // TODO: Initialize to an appropriate value
            Time expected = new Time(8, 59); // TODO: Initialize to an appropriate value
            Time actual = --(time);
            Assert.AreEqual<string>(expected.ToString(), actual.ToString());
        }

        [TestMethod()]
        public void op_IncrementTest()
        {
            Time time = new Time(9, 59); // TODO: Initialize to an appropriate value
            Time expected = new Time(10, 0); // TODO: Initialize to an appropriate value
            Time actual = ++(time);
            Assert.AreEqual<string>(expected.ToString(), actual.ToString());
        }
    }
}
